<template>
    <view class="user-container">
        <view class="user-box">
            <view class="head"></view>
            <div class="user-avatar flex-x-around-center">
                <image class="" src="@/static/image/user/avatar.png"></image>
            </div>
            <h-card padding="0 20rpx 10rpx" margin="0 0 30rpx 0" br="0">
                <view class="user-info">
                    <view class="item-row flex-x-start-center">
                        <image src="@/static/image/user/user.png"></image>
                        <text>姓名</text>
                        <view class="flex-grow-1"></view>
                        <text>{{userData.maintenanceStaffName}}</text>
                    </view>
                    <view class="item-row  flex-x-start-center">
                        <image src="@/static/image/user/phone.png"></image>
                        <text>手机号</text>
                        <view class="flex-grow-1"></view>
                        <text>{{userData.maintenanceStaffPhone}}</text>
                    </view>
                    <view class="item-row  flex-x-start-center" style="border-bottom: none">
                        <image src="@/static/image/user/group.png"></image>
                        <text>所在小组</text>
                        <view class="flex-grow-1"></view>
                        <text>{{userData.maintenanceGroupName}}</text>
                    </view>
                </view>
            </h-card>
            <h-card title="电子签名" br="0" margin="0 0 30rpx 0" v-if="$V.notEmpty(eSignature)">
                <image class="e-sign" :src="eSignature"></image>
            </h-card>
        </view>
        <u-button @click="goToSign" type="primary" size="large" >上传电子签名</u-button>
        <u-button @click="logout" size="large" custom-style="marginTop:20rpx;color: #F56657;backgroundColor: #FFFFFF">退出登录</u-button>
    </view>
</template>

<script>
import { getMaintenanceUserInfo, logout } from "@/api"
    export default {
        data() {
            return {
                //用户信息
                userData: {},
                //电子签名档
                eSignature:''

            };
        },
        onLoad() {},
        async onShow() {
            let _ = this
            _.getUserData()
        },
        methods: {
            async getUserData() {
                let _ = this
                const {data: res} = await getMaintenanceUserInfo()
                _.userData = res.data.maintenanceStaffLoginInfoVO || {}
                _.eSignature = _.$V.notEmpty(res.data.maintenanceStaffLoginInfoVO.electronicSignatureFile)?res.data.maintenanceStaffLoginInfoVO.electronicSignatureFile.filePath:''
            },
            goToSign() {
                let _ = this
                uni.$u.route('/pages_sub1/selfSign/index', {userId: _.userData.maintenanceStaffId})
            },
            logout() {
                let _ = this
                _.$T.showModal('是否确定退出登录', async () => {
                    const {data: res} = await logout()
                    if(res.code==200){
                        uni.removeStorageSync('Authorization')
                        uni.reLaunch({url: '/pages/login/index'})
                    }
                })
            },
            // /** 预览图片*/
            // previewPic(picList) {
            //     let _ = this
            //     uni.previewImage({
            //         current: '',
            //         urls: picList
            //     })
            // },
        }
    }
</script>

<style lang="scss">
    @import 'index.scss';
</style>
